Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed a deprecated method and corrected a typo in notebook 00 #833

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mazarrazi
Copy link

@mazarrazi mazarrazi commented Feb 20, 2024

  1. Typo @ line 1524,
    "| Matrix multiplication | [1*1 + 2*2 + 3*3] = [14] | tensor.matmul(tensor) |\n"

tensor.matmul(tensor) is replaced with torch.matmul(tensor)

  1. removed a deprecated method and corrected it accordingly @ line 2189
    The torch.Tensor.type() method is deprecated. It was used to change the data type of a tensor. However, this method is no longer recommended because it can lead to unexpected results.

Removed the code snippet torch.Tensor.type(dtype=None)

line 1524,
  "| **Matrix multiplication** | `[1*1 + 2*2 + 3*3]` = `[14]` | `tensor.matmul(tensor)` |\n"

tensor.matmul(tensor) is replaced with torch.matmul(tensor)
@mazarrazi mazarrazi changed the title Update 00_pytorch_fundamentals.ipynb Typo in notebook 00 Feb 20, 2024
The torch.Tensor.type() method is deprecated. It was used to change the data type of a tensor. However, this method is no longer recommended because it can lead to unexpected results.


Changed the code snippet from using torch.Tensor.type(dtype=None) to  tensor = tensor.to(torch.float32) for changing the datatype of tensors.  @ line 2189 under the "Change tensor datatype" heading

The link to the documentation has been updated accordingly.
The torch.Tensor.type() method is deprecated. It was used to change the data type of a tensor. However, this method is no longer recommended because it can lead to unexpected results.

Changed the code snippet from using `torch.Tensor.type(dtype=None)` to  `tensor = tensor.to(torch.float32)` for changing the datatype of tensors.  
@ line 2189 under the "Change tensor datatype" heading

The link to the documentation has been updated accordingly.
@mazarrazi mazarrazi changed the title Typo in notebook 00 removed a deprecated method and corrected a typo in notebook 00 Feb 20, 2024
The torch.Tensor.type() method is deprecated. It was used to change the data type of a tensor. However, this method is no longer recommended because it can lead to unexpected results.

Removed the code snippet `torch.Tensor.type(dtype=None)` 
@ line 2189
@mrdbourke
Copy link
Owner

Hey @mazarrazi ,

Thank you for this!

I appreciate the typo fix and am happy to merge that.

However, as for the torch.Tensor.type, I'm not sure that's deprecated? (I may be wrong, if so, please let me know).

I just ran this in Google Colab and it worked:

import torch

X = torch.tensor([1, 2, 3])
print(X, X.dtype)
X = X.type(dtype=torch.float32)
print(X, X.dtype)

Output:

tensor([1, 2, 3]) torch.int64
tensor([1., 2., 3.]) torch.float32
Screenshot 2024-08-22 at 9 04 36 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants